package bocchi.power;

import bocchi.BocchiCore;
import bocchi.base.BaseCustomPower;
import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.cards.DamageInfo.DamageType;
import com.megacrit.cardcrawl.core.AbstractCreature;

public class FortitudePower extends BaseCustomPower {
    private static final String RAW_ID = "Fortitude";
    public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public FortitudePower(AbstractCreature owner, int amount) {
        super(RAW_ID, PowerType.BUFF, owner, amount);
    }

    @Override
    public void updateDescription() {
        description = String.format(powerStrings.DESCRIPTIONS[0], amount);
    }

    @Override
    public int onAttackedToChangeDamage(DamageInfo info, int damageAmount) {
        if (info.type == DamageType.NORMAL && damageAmount > 0) {
            flash();
            damageAmount -= amount;
            damageAmount = Math.max(damageAmount, 0);
            addToTop(new ReducePowerAction(owner, owner, this, 1));
            return damageAmount;
        }

        return damageAmount;
    }

    @Override
    public void stackPower(int stackAmount) {
        super.stackPower(stackAmount);
    }
}
